Command-Line Options |
You can pass a file path in the command-line in order to tell KeePass to open
this file immediately after startup. Additionally, you can specify the password
and/or key-file location for this database. Switches can be either prefixed using
a slash (/) or a minus (-).
The database file location is passed as argument. Only one database file is allowed.
If the path contains a space, it must be enclosed in quotes (").
Passwords are passed using the -pw:
switch. In order to
pass 'abc' as password, you would add the following argument to the command-line:
-pw:abc
. Note that there's no space between the ':' and the
password.
For supplying the key-file location, the -keyfile:
switch
exists. The same rules as above apply, just that you specify the key-file location:
-keyfile:D:\pwsafe.key
.
In order to just pre-select a drive, without specifying the concrete key-file location
and/or password, use the -preselect:
option. For example, if you lock
your database with a password and a key-disk, but just want to type
in the password (so, without selecting the key-drive), your command-line would
look like this:
KeePass.exe "C:\My Documents\MyDatabase.kdb" -preselect:C:\
KeePass would then show you a prompt for the password for the database, but in
the key-disk list, the C:\
drive is selected already. When using the
preselect
switch, KeePass by default activates the 'and' checkbox
and sets the focus to the password edit window.
Note the difference! The preselect
switch just pre-selects the key-disk
for you and displays the login prompt. In contrast, the keyfile
switch
doesn't prompt you for the (maybe missing) password.
The order of the arguments doesn't matter.
Usage examples
Open the database file 'C:\My Documents\MyDatabase.kdb' (KeePass will prompt you
for the password and/or key-file location):
KeePass.exe "C:\My Documents\MyDatabase.kdb"
If you got a database that is locked with a password 'abc', you could open it like this:
KeePass.exe "C:\My Documents\MyDatabaseWithPw.kdb" -pw:abc
If your USB stick always mounts to drive F: and you've locked your database with the
USB stick as key-disk, you could open your database as follows:
KeePass.exe "C:\My Documents\MyDatabaseWithFile.kdb" -keyfile:F:\pwsafe.key
If you've locked your database using a password and a key-disk, you can combine
the two switches and open your database as follows:
KeePass.exe "C:\My Documents\MyDatabaseWithTwo.kdb" -pw:abc -keyfile:F:\pwsafe.key
You have your database locked using a password and a key-disk, but only
want to have the key-disk pre-selected (i.e. you want to get prompted for the
password only), your command-line would look like:
KeePass.exe "C:\My Documents\MyDatabaseWithTwo.kdb" -preselect:F:\
KeePass would pre-select the drive F:\
for you.
You can also pre-select files instead of drives, in this case the switch would look like
this: -preselect:"D:\My Documents\DB_Key.key"
.